package com.bicon.botu.mall.order.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.bicon.botu.mall.order.dto.*;
import com.bicon.botu.mall.order.entity.AfterSalesRecords;
import com.bicon.botu.mall.order.param.AfterSalesParam;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单退款退货记录 服务类
 * </p>
 *
 * @author 李双喜
 * @since 2018-06-14
 */
public interface IAfterSalesRecordsService extends IService<AfterSalesRecords> {
    /**
     * 申请退货退款
     *
     * @param afterSalesParamJson 申请退货实体
     * @return
     */
    String applyAfterSales(String afterSalesParamJson);

    /**
     * 计算退费金额
     *
     * @param orderChildIds 多个子订单id  逗号隔开
     * @return
     */
    Map<String, BigDecimal> calcPayBackAmount(String orderChildIds);

    /**
     * 分页查询售后订单
     *
     * @param page
     * @param params
     * @return
     */
    Page<AfterSalesItemDto> getAfterSalesPageByCondition(Page<AfterSalesItemDto> page, Map<String, String> params);

    /**
     * 根据id查询详情
     *
     * @param id 申请售后id
     * @return
     */
    AfterSaleDetailDto forDetails(String id) throws ParseException;

    /**
     * 统计各状态的售后申请数量
     *
     * @param storeId
     * @return
     */
    List<AfterSalesStatisticsDto> statisticAfterSale(String storeId);

    /**
     * 查询售后申请明细
     *
     * @param afterSalesId
     * @return
     */
    AfterSalesForWebDto queryAfterSalesRecords(String afterSalesId);

    /**
     * 查询退货申请商品列表
     *
     * @param afterSalesId
     * @param pageNo
     * @param pageSize     @return
     */
    Page<AfterSalesDetailsDto> queryAfterSalesGoodsList(String afterSalesId, Integer pageNo, Integer pageSize);


    /**
     * 撤销申请
     *
     * @param id 申请售后id
     * @return
     */
    String forRepeal(String id);

    /**
     * 修改申请
     *
     * @param afterSalesParamJson 售后订单json
     * @return
     */
    String modifyAfterSales(String afterSalesParamJson);

    /**
     * 退货发货单填写
     *
     * @param id                   申请退款id
     * @param deliveryPointId      物流公司id
     * @param logisticsCode        运单号
     * @param logisticsDescription 物流描述
     * @return
     */
    Boolean commitLogistics(String id, String deliveryPointId, String logisticsCode, String logisticsDescription);

    /**
     * @param afterSalesId
     * @param approvalResult
     * @param payBackFreight
     * @param payBackAmount
     * @param deliveryPointId
     * @param backDeliveryMethod
     * @param rejectReason
     * @return
     */
    boolean approvalAfterSales(String afterSalesId, boolean approvalResult, boolean payBackFreight, BigDecimal payBackAmount,
                               String deliveryPointId, Integer backDeliveryMethod, String rejectReason, String userId);

    /**
     * 确认收货
     *
     * @param userId       用户ID
     * @param afterSalesId 售后记录ID
     * @return
     */
    boolean receivedGoods(String userId, String afterSalesId);

    /**
     * 导出售后单状态
     *
     * @param params
     */
    void exportRecords(Map<String, String> params, HttpServletRequest request, HttpServletResponse response);


    /**
     * 跟据订单号，查询物流信息
     *
     * @param afterSalesId 申请售后id
     * @return
     */
    OrderLogisticsDto getLogistics(String afterSalesId);
}
